<template>
  <v-card
    :title="tag == 1 ? '已完成车辆动态信息' : '已完成火车动态信息'"
    bgImg="https://oss.sdland-sea.com/group2/M01/16/06/Cof8E2IxgOCAYlXeAACSfyrQms0977.png"
  >
    <div class="card-container">
      <div class="list-header">
        <div class="checi" v-if="tag == 2">车次</div>
        <div class="gangkou">港口</div>
        <div class="gangqu" :class="{ train: tag == 2 }">港区</div>
        <div class="cheliang">车辆状态</div>
        <div class="yunshu">运输时长</div>
        <div class="chepaihao" v-if="tag == 1">
          车牌号
        </div>
        <div class="mudidi" v-if="tag == 1">司机</div>
        <div class="huoming">货物名称</div>
        <div class="pizhong">
          {{ tag == 1 ? "入厂毛重(t)" : "出港净重(t)" }}
        </div>
        <div class="maozhong">
          {{ tag == 1 ? "出厂皮重(t)" : "卸货净重(t)" }}
        </div>
        <div class="yudi">货损(t)</div>
      </div>
      <div class="list-body">
        <div :id="id" class="swiper mySwiperCont">
          <div
            class="swiper-wrapper "
            :class="{ flexSwiperWrapper: listData.length < maxLength }"
          >
            <div
              class="swiper-slide"
              v-for="(item, index) in listData"
              :key="index"
            >
              <div class="list-item">
                <div class="checi" v-if="tag == 2">
                  {{ item.sequence || "未知" }}
                </div>
                <div class="gangkou">{{ item.port || "未知" }}</div>
                <div class="gangqu" :class="{ train: tag == 2 }">
                  {{ item.portArea || "未知" }}
                </div>
                <div class="cheliang">{{ item.carStatus || "未知" }}</div>

                <div class="yunshu">{{ item.transportLen }} h</div>
                <div class="chepaihao" v-if="tag == 1">
                  {{ item.carNo || "未知" }}
                </div>
                <div class="mudidi" v-if="tag == 1">
                  {{ item.driver || "未知" }}
                </div>
                <div class="huoming">{{ item.cargoName }}</div>
                <div class="pizhong">{{ item.grossWeight }}</div>
                <div class="maozhong">
                  {{ tag == 1 ? item.tareWeight : item.netWeight }}
                </div>
                <div class="yudi">{{ item.lossWeight }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </v-card>
</template>

<script>
import MIXIN from "./mxin";
import { getPortSuccessInfo } from "@/api/networShow/dataV";
export default {
  mixins: [MIXIN],
  data() {
    return {
      id: "PortSuccessInfo",
      maxLength: 2
    };
  },
  methods: {
    async getListData() {
      this.listData = [];
      const { data } = await getPortSuccessInfo(this.tag);
      if (data.code == 200) {
        this.listData = data.data;
      }
    }
  }
};
</script>

<style lang="less" scoped>
.card-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .list-header,
  .list-item {
    width: 100%;
    display: flex;
    height: 22px;
    line-height: 22px;
    background: rgba(216, 216, 216, 0.25);
    font-size: 12px;
    font-family: SourceHanSansCN-Bold, SourceHanSansCN;
    font-weight: bold;
    color: #ffffff;
    display: flex;
    & > div {
      // white-space: nowrap;
      // overflow: hidden;
      // text-overflow: ellipsis;
      padding: 0 2px;
      box-sizing: border-box;
    }
    .checi {
      width: 95px;
    }
    .gangkou {
      width: 50px;
    }
    .gangqu {
      // width: 43px;
      width: 55px;
    }
    .cheliang {
      width: 58px;
    }
    .mudidi {
      width: 45px;
    }
    .yudi {
      width: 55px;
    }
    .yunshu {
      width: 55px;
    }
    .chepaihao {
      width: 68px;
    }
    .huoming {
      width: 52px;
    }
    .pizhong {
      flex: 1;
    }
    .maozhong {
      flex: 1;
    }
  }
  .list-body {
    flex: 1;
    .flexSwiperWrapper {
      display: flex;
      flex-direction: column;
      .swiper-slide {
        height: 44px;
        line-height: 44px;
      }
    }
    .mySwiperCont {
      height: 101px;
      .swiper-slide {
        &:nth-child(odd) {
          .list-item {
            background: transparent;
          }
        }
        &:nth-child(even) {
          .list-item {
            background: rgba(56, 64, 138, 0.25);
          }
        }
      }
      .list-item {
        padding: 3px 0;
        height: auto;
        // line-height: 34px;
        align-items: center; /*实现水平居中*/
      }
    }
  }
}
</style>
